//
//  ViewController.m
//  mora
//
//  Created by zhuwansan on 15/7/17.
//  Copyright (c) 2015年 zhuwansan. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
//@property (weak, nonatomic) IBOutlet UIButton *bu;
//@property (weak, nonatomic) IBOutlet UIButton *jiandao;
//@property (weak, nonatomic) IBOutlet UIButton *shitou;

@property (weak, nonatomic) IBOutlet UILabel *result;
@property (strong, nonatomic) IBOutlet UILabel *victor;
@property (strong, nonatomic) IBOutlet UILabel *failure;
@property (strong, nonatomic) IBOutlet UILabel *close;


@end

long player = 0;
long computer = 0;
/**
 *   v代表玩家胜利
     c代表平局
     f代表玩家数了
 */
int v,f,c = 0;

@implementation ViewController



- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.result.backgroundColor = [UIColor redColor];
    self.victor.backgroundColor = [UIColor greenColor];
    self.failure.backgroundColor = [UIColor greenColor];
    self.close.backgroundColor = [UIColor greenColor];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}





- (IBAction)chuquan:(UIButton *)button{
   

    
//    设置按钮的颜色
    button.backgroundColor = [UIColor brownColor];
    //电脑产生随机数0-2
    computer = arc4random()%3;
   //获取玩家出拳的按钮tag
    switch (button.tag) {
        case 0://如果出剪刀就给玩家赋值0
            player = 0;
            NSLog(@"p 剪刀");

           //比较结果并输出在标签上
            switch (computer) {
                case 0:
                    self.result.text = @"可以啊，居然和我打平了";
                    //每点击一次总有一个数增加1
                    c = c+1;
                    
                    NSLog(@"s 剪刀");
                    break;
                case 1:
                    self.result.text = @"小样啊，被我打败了吧";
                    f = f+1;
                    NSLog(@"s 石头");
                    break;
                    
                case 2:
                    self.result.text = @"厉害啊，居然战胜我了";
                    v = v+1;
                    NSLog(@"s 布");
                    
                    break;
                    
            }

             break;
        case 1://如果出石头就给玩家赋值1
            player = 1;
            NSLog(@"p 石头");

            //比较结果并输出在标签上
            switch (computer) {
                case 0:
                    self.result.text = @"厉害啊，居然战胜我了";
                    //每点击一次总有一个数增加1
                    v = v+1;
                    
                    NSLog(@"s 剪刀");
                    break;
                case 1:
                    self.result.text = @"可以啊，居然和我打平了";
                    c = c+1;
                    NSLog(@"s 石头");
                    break;
                    
                case 2:
                    self.result.text = @"小样啊，gg吧";
                    f = f+1;
                    NSLog(@"s 布");
                    
                    break;
                    
            }

            break;
        case 2://如果出布就给玩家赋值2
            player = 2;
            NSLog(@"p 布");

            //比较结果并输出在标签上
            switch (computer) {
                case 0:
                    self.result.text = @"小样啊，被我打败了吧";
                    //每点击一次总有一个数增加1
                    f = f+1;
                    
                    NSLog(@"s 剪刀");
                    break;
                case 1:
                    self.result.text = @"厉害啊，居然战胜我了";
                    v = v+1;
                    NSLog(@"s 石头");
                    break;
                    
                case 2:
                    self.result.text = @"可以啊，居然和我打平了";
                    c = c+1;
                    NSLog(@"s 布");
                    
                    break;
                    
            }

            break;
           }
    self.victor.text = [NSString stringWithFormat:@"%d",v];
    self.failure.text = [NSString stringWithFormat:@"%d",f];
    self.close.text = [NSString stringWithFormat:@"%d",c];
    
}
-(void)vs{
   }




@end
